#pragma once
#include <Windows.h>
#include <string>
#include "../locker.h"

class GroupServerEvent {
public:
    virtual void OnRecvData(const std::string &strRecved, std::string &strResp) = 0;
};

class CGroupServer {
public:
    CGroupServer();
    virtual ~CGroupServer();

    bool Start(const std::string &strGroupIp, USHORT nPort, GroupServerEvent *pListener);
    void Stop();
private:
    static DWORD WINAPI RecvThread(LPVOID pParam);

private:
    bool m_bInitSuccess;
    HANDLE m_hRecvThread;
    UINT_PTR m_nServerSocket;
    std::string m_strGroupIp;
    USHORT m_nLocalPort;

    GroupServerEvent *m_pListener;
};